<?php

namespace Drupal\shushengyuan\Schemas;

use Drupal\shusy_topic\Entity\ShusyTopic;

/**
 * @OA\Schema(
 *   schema="TopicItem",
 *   type="object",
 *   description="TopicItem"
 * )
 */
class TopicItem extends AbstractBaseModel {

  protected function getEntityType() {
    return 'shusy_topic';
  }

  protected function setValue() {
    if ($this->entity instanceof ShusyTopic) {
      $value = [
        /**
         * @OA\Property(
         *   property="id",
         *   type="integer",
         *   description="ID",
         * ),
         */
        'id' => (int) $this->entity->id,
        /**
         * @OA\Property(
         *   property="title",
         *   type="string",
         *   description="话题",
         * ),
         */
        'title' => (string) $this->entity->title,
      ];
      $this->merge($value);
    }
  }
}
